﻿using System;
using GigaSite.Domain.Entities;
using Newtonsoft.Json;

namespace GigaSite.Web.Areas.ControlPanel.Models
{
    /// <summary>
    /// Модель торгового центра
    /// </summary>
    public class ShoppingMallModel
    {
        /// <summary>
        /// Идентификатор торгового центра
        /// </summary>
        [JsonProperty("id")]
        public long Id { get; set; }

        /// <summary>
        /// Отображаемое имя
        /// </summary>
        [JsonProperty("displayName")]
        public string DisplayName { get; set; }

        /// <summary>
        /// Системное имя
        /// </summary>
        [JsonProperty("systemName")]
        public string SystemName { get; set; }

        /// <summary>
        /// Описание
        /// </summary>
        [JsonProperty("description")]
        public string Description { get; set; }

        /// <summary>
        /// Просмотров
        /// </summary>
        [JsonProperty("views")]
        public int Views { get; set; }

        /// <summary>
        /// Адрес
        /// </summary>
        [JsonProperty("address")]
        public string Address { get; set; }

        /// <summary>
        /// Широта
        /// </summary>
        [JsonProperty("latitude")]
        public double Latitude { get; set; }

        /// <summary>
        /// Долгота
        /// </summary>
        [JsonProperty("longitude")]
        public double Longitude { get; set; }

        /// <summary>
        /// URL логотипа
        /// </summary>
        [JsonProperty("logo")]
        public string LogoImage { get; set; }

        /// <summary>
        /// Дата создания
        /// </summary>
        [JsonProperty("dateCreated")]
        public DateTime? DateCreated { get; set; }

        /// <summary>
        /// Дата модификации
        /// </summary>
        [JsonProperty("dateModified")]
        public DateTime? DateModified { get; set; }

        /// <summary>
        /// Количество организаций в торговом центре
        /// </summary>
        [JsonProperty("organizations")]
        public int Organizations { get; set; }

        /// <summary>
        /// Город в котором находится торговый центр
        /// </summary>
        [JsonProperty("city")]
        public string City { get; set; }

        /// <summary>
        /// Простой конструктор
        /// </summary>
        public ShoppingMallModel()
        {
        }

        /// <summary>
        /// Инициализирует модель торгового центра и заполняет ее данными из доменного объекта
        /// </summary>
        /// <param name="shoppingMall">Доменный торговый центр</param>
        public ShoppingMallModel(ShoppingMall shoppingMall)
        {
            Id = shoppingMall.Id;
            DisplayName = shoppingMall.DisplayName;
            SystemName = shoppingMall.SystemName;
            Description = shoppingMall.Description;
            Views = shoppingMall.Views;
            Address = shoppingMall.Address;
            Latitude = shoppingMall.Latitude;
            Longitude = shoppingMall.Longitude;
            LogoImage = shoppingMall.LogoImage;
            DateCreated = shoppingMall.DateCreated;
            DateModified = shoppingMall.DateModified;
            Organizations = 0;
            City = shoppingMall.City.DisplayName;
        }
    }
}